package com.app.couponsharelife.ui.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.view.WindowManager
import com.app.couponsharelife.R
import com.app.couponsharelife.ui.listener.OnClickListener

/**
 * Created by guluwa on 2018/12/2.
 */
class BotShareDialog(context: Context, themeResId: Int, val listener: OnClickListener) : Dialog(context, themeResId) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.bot_share_dialog)
        initView()
    }

    //页面初始化
    private fun initView() {
        initDialog()
        initClickListener()
    }

    //Dialog初始化
    private fun initDialog() {
        window!!.setGravity(Gravity.BOTTOM)
        window!!.setWindowAnimations(R.style.picker_view_slide_anim)
        setCanceledOnTouchOutside(true)
        //设置dialog没有边距
        window!!.decorView.setPadding(0, 0, 0, 0)
        val lp = window!!.attributes
        lp.width = WindowManager.LayoutParams.MATCH_PARENT
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT
        window!!.attributes = lp
    }

    private fun initClickListener() {
        findViewById<View>(R.id.mShareWechatView).setOnClickListener {
            listener.click(0, "")
            dismiss()
        }
        findViewById<View>(R.id.mShareCircleView).setOnClickListener {
            listener.click(1, "")
            dismiss()
        }
        findViewById<View>(R.id.tvCancel).setOnClickListener {
            dismiss()
        }
    }
}